package com.yuewen;

import com.yuewen.test2.PersonServer;
import com.yuewen.test1.Car;
import com.yuewen.test3.UserService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

/**
 * Created by liwei.b on 2017/6/20.
 * http://blog.csdn.net/daguanjia11/article/details/49278003
 */
public class Startup {
    @Test
    public void test1() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        Car car = (Car) context.getBean("car");
        car.go("1", 21);
    }

    @Test
    public void test2() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean2.xml");
        PersonServer bean = (PersonServer) context.getBean("personServiceBean");
        bean.save(null);
    }

    @Test
    public void test3() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean3.xml");
        UserService userService  = context.getBean(UserService.class);
        System.out.println(userService.getById(1111));
    }
}
